<html>
<head>
<title>{{instance}}</title>
<style type="text/css">
body {
  font-family: Helvetica, Arial, sans-serif;
  font-size: 14pt;
}

h1 { border: solid 1pt black; text-align: center;font-size: 16pt; }
h2 { font-size: 14pt; }

p.Recipient, p.Subject {
  font-weight: bold;
}

p.Recipient, p.Date, p.Signature {
  margin-left: 70mm;
}

#footerContent { text-align: right; font-size: 8pt; }

table.items {
  table-layout:fixed; background-color:white; padding: 2mm;
}
table.items th { background-color:gray; padding: 1mm; text-align:left;}
td.number { text-align:right; }
table.tech td {
  background-color:#eeeeee;
}
table.total tr { background-color:gray; padding: 1mm; }


@page {

  margin:2cm;
  margin-left:3cm;
  margin-bottom:25mm;
  margin-top:45mm;
  -pdf-frame-border: 1; 
  
  @frameheader {
    -pdf-frame-content:headerContent;
    top:10mm;
    height:33mm;
    margin-left:1cm;
    margin-right:1cm;
    -pdf-frame-border: 1; 
  }

  @framefooter {
    -pdf-frame-content:footerContent;
    bottom:1cm;
    margin-left:3cm;
    margin-right:2cm;
    height:1cm;
    -pdf-frame-border: 1; 
  }
}

</style>
</head>
<body>

<div id="footerContent">
[page <pdf:pagenumber>]
</div>

<div id="headerContent">
<table>
<tr>
<td>
<img src="{{ MEDIA_URL }}logo.jpg" width="30mm"/>
</td>
<td style="text-align:center;width:60mm">
<b><font size="7">igen demo</font></b>
</td>
<td style="text-align:right; font-size:8pt;width:100mm">
<br/>Tartu mnt 71-5, 10115 Tallinn
<br/>Tel +372/4824548
<br/>GSM +372/56672435
<br/>http://igen.saffre-rumma.ee
</td>
</tr>
</table>
</div>

<pdf:spacer height="20mm">

<p class="Recipient" style="margin-left:70mm;font-weight: bold;">
{{instance.customer}}<br>
{{instance.customer.as_address}}

<pdf:spacer height="20mm">

<p class="Date" style="margin-left: 70mm;">
{{instance.creation_date}}
</p>

<p class="Subject" style="font-weight: bold; width:100%; border-bottom: solid 1pt black">
{{instance}} / {{instance.your_ref}}
</p>

{{instance.intro}}

<table class="items" repeat="1">
<tr>
<th style="width:15mm;">pos</th>
<th style="width:125mm;">title</th>
<th style="width:20mm;">unit price</th>
<th style="width:20mm;">qty</th>
<th style="width:20mm;">total excl</th>
</tr>

{% for item in instance.docitem_set.all %}
<tr>
<td class="number">{{ item.pos }}</td>
<td>{{ item.title }}</td>
<td class="number">{{ item.unit_price }}</td>
<td class="number">{{ item.qty }}</td>
<td class="number">{{ item.total_excl }}</td>
</tr>
{% endfor %}

</table>

<table class="total">
<tr>
  <td style="width:130mm; font-size:10pt" rowspan="3" valign="top">
  Our general terms and conditions apply.
  <br/>Invoicing mode: <b>{{instance.imode}}</b>
  <br/>Payment term: <b>{{instance.payment_term}}</b>
  <br/>Shipping mode: <b>{{instance.shipping_mode}}</b>
  </td>
  <td style="width:40mm; text-align:right;">Total htva:</td>
  <td style="width:20mm;" class="number">{{instance.total_excl}}</td></tr>
<tr>
  <td style="width:40mm; text-align:right;">TVA:</td>
  <td style="width:20mm;" class="number">{{instance.total_vat}}</td>
</tr>
<tr>
  <td style="width:40mm; text-align:right;">Total to pay:</td>
  <td style="width:20mm;" class="number">{{instance.total_incl}}</td></tr>
</table>

</body>
</html>
